bitkeeper revision 1.1234 (421b3fb4-44X_GoE5Kjk9WGfmRE_rg)
authormaf46@burn.cl.cam.ac.uk <maf46@burn.cl.cam.ac.uk>
Tue, 22 Feb 2005 14:20:36 +0000 (14:20 +0000)
committermaf46@burn.cl.cam.ac.uk <maf46@burn.cl.cam.ac.uk>
Tue, 22 Feb 2005 14:20:36 +0000 (14:20 +0000)
Move the phys-to-mach map from PERDOMAIN_VIRT_START to
RO_MPT_VIRT_START (which isn't otherwise used by
shadow_mode_shadow()==true domains).

Signed-off-by: michael.fetterman@cl.cam.ac.uk
xen/arch/x86/domain.c
xen/arch/x86/x86_32/mm.c
xen/include/asm-x86/mm.h

index cb9643a262183122d58f243a69324ea62a9e8a67..1bffcb6eb360bc24b677a1cb96c954da00ecf759 100644 (file)
@@ -299,7 +299,7 @@ void arch_vmx_do_launch(struct exec_domain *ed)
 static void alloc_monitor_pagetable(struct exec_domain *ed)
 {
     unsigned long mmfn;
-    l2_pgentry_t *mpl2e, *phys_table;
+    l2_pgentry_t *mpl2e;
     struct pfn_info *mmfn_info;
     struct domain *d = ed->domain;
 
@@ -323,12 +323,9 @@ static void alloc_monitor_pagetable(struct exec_domain *ed)
     ed->arch.monitor_table = mk_pagetable(mmfn << PAGE_SHIFT);
     ed->arch.monitor_vtable = mpl2e;
 
-    phys_table = (l2_pgentry_t *)
-        map_domain_mem(pagetable_val(ed->arch.phys_table));
-    memcpy(d->arch.mm_perdomain_pt, phys_table,
-           L1_PAGETABLE_ENTRIES * sizeof(l1_pgentry_t));
-
-    unmap_domain_mem(phys_table);
+    // map the phys_to_machine map into the Read-Only MPT space for this domain
+    mpl2e[l2_table_offset(RO_MPT_VIRT_START)] =
+        mk_l2_pgentry(pagetable_val(ed->arch.phys_table) | __PAGE_HYPERVISOR);
 }
 
 /*
index 788e7c12415e5e6a654768615f36a0f2c71757f2..0ba7feff7f0b8b2fb470302d90c044e1a88bca36 100644 (file)
@@ -119,10 +119,14 @@ void __init paging_init(void)
     idle_pg_table[l2_table_offset(IOREMAP_VIRT_START)] =
         mk_l2_pgentry(__pa(ioremap_pt) | __PAGE_HYPERVISOR);
 
-    /* Create read-only mapping of MPT for guest-OS use. */
+    /* Create read-only mapping of MPT for guest-OS use.
+     * NB. Remove the global bit so that shadow_mode_translate()==true domains
+     *     can reused this address space for their phys-to-machine mapping.
+     */
     idle_pg_table[l2_table_offset(RO_MPT_VIRT_START)] =
         mk_l2_pgentry(l2_pgentry_val(
-            idle_pg_table[l2_table_offset(RDWR_MPT_VIRT_START)]) & ~_PAGE_RW);
+                          idle_pg_table[l2_table_offset(RDWR_MPT_VIRT_START)]) &
+                      ~(_PAGE_RW | _PAGE_GLOBAL));
 
     /* Set up mapping cache for domain pages. */
     mapcache = (unsigned long *)alloc_xenheap_page();
index 1d0cf33c24e00ce0552265cd21f55e9263b27f1e..3e4b1d4b0b51f16581f75f61e876f11a2f9db035 100644 (file)
@@ -235,9 +235,11 @@ void synchronise_pagetables(unsigned long cpu_mask);
 
 /*
  * The phys_to_machine_mapping is the reversed mapping of MPT for full
- * virtualization.
+ * virtualization.  It is only used by shadow_mode_translate()==true
+ * guests, so we steal the address space that would have normally
+ * been used by the read-only MPT map.
  */
-#define __phys_to_machine_mapping ((unsigned long *)PERDOMAIN_VIRT_START)
+#define __phys_to_machine_mapping ((unsigned long *)RO_MPT_VIRT_START)
 
 /* Returns the machine physical */
 static inline unsigned long phys_to_machine_mapping(unsigned long pfn) 
@@ -245,11 +247,11 @@ static inline unsigned long phys_to_machine_mapping(unsigned long pfn)
     unsigned long mfn;
     l1_pgentry_t pte;
 
-   if (__get_user(l1_pgentry_val(pte), (__phys_to_machine_mapping + pfn))) {
-       return 0;
-   }
-               
-   mfn = l1_pgentry_to_phys(pte) >> PAGE_SHIFT;
+   if (__get_user(l1_pgentry_val(pte), (__phys_to_machine_mapping + pfn)))
+       mfn = 0;
+   else
+       mfn = l1_pgentry_to_phys(pte) >> PAGE_SHIFT;
+
    return mfn; 
 }
 #define set_machinetophys(_mfn, _pfn) machine_to_phys_mapping[(_mfn)] = (_pfn)